package com.Springexample.demo;

import com.Springexample.demo.service.AnotherService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;

// 使用 @ImportResource 注解导入 XML 配置文件
// “classpath:” 表示从 resources 目录下查找
@ImportResource("classpath:spring-context.xml")
@SpringBootApplication
public class DemoApplication {

	public static void main(String[] args) {
		// 启动应用并获取应用上下文
		var context = SpringApplication.run(DemoApplication.class, args);

		// 从容器中获取由 XML 配置的 Bean
		AnotherService anotherService = context.getBean(AnotherService.class);
		anotherService.printMessage(); // 输出：AnotherService is calling: Hello from MyService, XML Config!
	}
}